home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume2 / shstat < prev    next >
Encoding:
Internet Message Format  |  1991-08-07  |  3.4 KB

  1. From: jv@mh.nl.UUCP (Johan Vromans)
  2. Newsgroups: comp.sources.misc
  3. Subject: v02i058: shstat - system status display (System V)
  4. Message-ID: <7241@ncoast.UUCP>
  5. Date: 18 Feb 88 02:34:23 GMT
  6. Approved: allbery@ncoast.UUCP
  7.  
  8. Comp.sources.misc: Volume 2, Issue 58
  9. Submitted-By: "Johna Vromans" <jv@mh.nl>
  10. Archive-Name: shstat
  11.  
  12. This is a little shell script which repeatedly displays the system
  13. status, leaving out uninteresting info. It is essentially a "ps -ef"
  14. post-processor. It can (and should) be tailored for your own system.
  15.  
  16. It will probably be blown away by some nifty perl program in the near
  17. future, or by a program using some kind of "ptw" (process-tree-walk) function.
  18. Until then ... have fun.
  19.  
  20. By the way - this is a X/OPEN (or System V) compliant script. There's
  21. enough BSD-only software in the world already.
  22.  
  23. --
  24. Johan Vromans                              | jv@mh.nl via European backbone
  25. Multihouse N.V., Gouda, the Netherlands    | uucp: ..{uunet!}mcvax!mh.nl!jv
  26. "It is better to light a candle than to curse the darkness"
  27.  
  28. #-------------------------------- CUT HERE --------------------------------
  29. #! /bin/sh
  30. # This is a shell archive, meaning:
  31. # 1. Remove everything above the #! /bin/sh line.
  32. # 2. Save the resulting text in a file.
  33. # 3. Execute the file with /bin/sh (not csh) to create:
  34. #    shstat.sh
  35. # This archive created: Mon Feb 15 22:16:51 1988
  36. export PATH; PATH=/bin:/usr/bin:$PATH
  37. if test -f 'shstat.sh'
  38. then
  39.     echo shar: "will not over-write existing file 'shstat.sh'"
  40. else
  41. cat << \SHAR_EOF > 'shstat.sh'
  42. #!/bin/sh
  43.  
  44. # @(#)@ show_status    1.9    show system activity
  45. # @(#)@ Copyright 1988 by Johan Vromans - Multihouse Research
  46. # Contributed to Public Domain by the Author, Feb 15, 1988
  47.  
  48. # This is a little shell script which repeatedly displays the current
  49. # system activity, filtering out unneeded entries.
  50. #
  51. # Display uses tty enhancements, if present.
  52. #
  53. # Usage: show_status [ sleep-value ]
  54.  
  55. title="Multihouse USENET Gateway"    # descriptive title of this system
  56.  
  57. trap "rm -f /tmp/tmpa$$; trap '' 0; exit" 0 1 2 3 15
  58.  
  59. # get display interval
  60. sleep="$1"
  61. if [ "$sleep" = "" ]
  62. then
  63.     sleep=20
  64. fi
  65.  
  66. # get terminal enhancements
  67. home=`tput home`
  68. home=${home:-`tput khome`}
  69. home=${home:-`tput clear`}
  70. clear=`tput ed`
  71. cln=`tput el`
  72. so=`tput smso`
  73. se=`tput rmso`
  74.  
  75. # please keep the next line intact
  76. echo "$home`tput clear`show_status version 1.9 - Multihouse Research"
  77.  
  78. # build top display line
  79. line=`ps -f | line | sed \
  80.     -e "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" \
  81.     -e "s/^\(.....................\).../\1/"`
  82. line="$so$line    $se"
  83.  
  84. # other relevant data
  85. pid=$$
  86. set `uname -a`    # KEEP LAST - SCRIPT USES $1, $2 and so on ...
  87.  
  88. # and here we go ... until interrupted
  89. while [ a = a ]
  90. do
  91.     echo "$home$so $2   $1/$3   `date`    $title $se$cln\n"
  92.     # don't use a pipe - unwanted processes show up!
  93.     ps -ef > /tmp/tmpa$$
  94.     echo "$line"
  95.     sort +1n -2 < /tmp/tmpa$$ | sed        \
  96.         -e "/ -sh/d"            \
  97.         -e "/ -csh/d"            \
  98.         -e "/ -ksh/d"            \
  99.         -e "1d"                \
  100.         -e "/ $pid /d"            \
  101.         -e "\./etc/getty.d"        \
  102.         -e "s/^\(.....................\).../\1/"    \
  103.         -e "s/\$/$cln/"
  104.     echo "$clear\c"
  105.  
  106.     sleep $sleep
  107. done
  108. SHAR_EOF
  109. if test 1583 -ne "`wc -c < 'shstat.sh'`"
  110. then
  111.     echo shar: "error transmitting 'shstat.sh'" '(should have been 1583 characters)'
  112. fi
  113. fi
  114. exit 0
  115. #    End of shell archive
  116. -- 
  117. Johan Vromans                              | jv@mh.nl via European backbone
  118. Multihouse N.V., Gouda, the Netherlands    | uucp: ..{uunet!}mcvax!mh.nl!jv
  119. "It is better to light a candle than to curse the darkness"
  120.